<%@ tag language="java" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<%@ attribute name="replace" type="java.lang.String" required="true" description="需要替换的textarea编号"%>
<%@ attribute name="height" type="java.lang.String" required="false" description="编辑器高度"%>
<%@ attribute name="readonly" type="java.lang.String" required="false" description="编辑器只读"%>
<%@ attribute name="objectId" type="java.lang.String" required="true" description="上传附件或图片对象ID"%>
<%@ attribute name="objectType" type="java.lang.String" required="true" description="上传附件或图片对象类型"%>
<script type="text/javascript" >
	var attacheuploador;
	KindEditor.ready(function(K) {
		    attacheuploador = K.uploadbutton({
			button : K('#uploadButton')[0],
			fieldName : 'attachement',
			url : '${ctx}/basic/kindeditor/upload?objectId=${objectId}&objectType=${objectType}',
			afterUpload : function(data) {
				if (data.error === 0) {
					var url = K.formatUrl(data.url, 'absolute');
				} else {
					alert(data.message);
				}
			},
			afterError : function(str) {
				alert('自定义错误信息: ' + str);
			}
		});
		attacheuploador.fileBox.change(function(e) {
		    	attacheuploador.submit();
		});
	});
</script>
<input type="button" id="uploadButton" value="Upload" class="file-upload-btn"/>